(function() {
    'use strict';

    angular
        .module('milkbeeApp')
        .controller('NavigatorController', NavigatorController);

    NavigatorController.$inject = ['$state', 'Auth', 'TreeCategory','Principal', 'ProfileService', 'LoginService'];

    function NavigatorController ($state,Auth,TreeCategory,  Principal, ProfileService, LoginService) {
        var vm = this;

        vm.categories={};
        //vm.reload=reload;
        function load(){
        	var pid=0;
        	if($state.parentId){
        		pid=$state.parentId;
        	}
        	TreeCategory.query({
        		//parentId:pid
            },onSuccess, onError);
            function onSuccess(data) {
                vm.categories = data;
            }
            function onError(error) {
               // AlertService.error(error.data.message);
            	//alert(1);
            }
        }
        /**
        function reload(pid){
        	SubCategory.query({
        		parentId:pid
            },onSuccess, onError);
            function onSuccess(data) {
                
                if(data.length>0){
                	vm.categories = data;
                	return;
                }
                
                $state.go('card-category', {categoryId:pid}, { reload: false });
            }
            function onError(error) {
            }
        };
        **/
        load();
    }
})();
